home *** CD-ROM | disk | FTP | other *** search
- Path: gate.net!pslfl2-23
- From: bhutto@gate.net (William Hutto)
- Newsgroups: comp.lang.c
- Subject: Re: extern and static are they compatable
- Date: 5 Jan 1996 02:44:40 GMT
- Organization: CyberGate, Inc.
- Message-ID: <4ci3ao$f84@news.gate.net>
- References: <4cedhf$g6i@cnn.cc.biu.ac.il> <ahicksDKM8Ap.FBp@netcom.com>
- NNTP-Posting-Host: pslfl2-44.gate.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <ahicksDKM8Ap.FBp@netcom.com>,
- ahicks@netcom.com (Aaron Hicks at Netcom) wrote:
- >Folks,
- >
- > I'm working on a project which requires use to create large array
- >( approximately 500 K bytes ) so we decided to make it static so it would
- >not have be created each time the routines that use it are called. We then
- >found out that we needed a nother program to acess this array so in the
- second
- >file we defined this array as a extern. Now each time we compile and link
- >the programs we get an error stating that the array is undefined. The error
- >is displayed while linking. After reading all I could find about extern
- >I can not find any thing that says this is correct behavior. I then changed
- >the static decloration to a non static and the thing compiles with out a
- >problem. Now I'm wandering if any of the great mind on the net could
- >enlighten me as to why the static declaration would cause this error.
-
- <snip>
-
- If you explicitely use the _static_ keyword you limit an object's scope to
- _file_. This holds true for functions as well:
-
- static void func(void)
- {
- }
-
- can only be called from within it's own file. This can be a somewhat effective
- means of code and data hiding in C.
-
- Bill
-
- "Whatcha got on?...Your mind?"
-